% Copyright (c) 2020 NVI, Inc.
%
% This file is part of VLBI Field System
% (see http://github.com/nvi-inc/fs).
%
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program. If not, see <http://www.gnu.org/licenses/>.
 
function out=contour_holog(grid,azc,azs,elc,els,levels)
%contour map of data grid generated by holog program
%input
% grid   = rectangular matrix of data
% azc    = center of az range
% azs    = az step size
% elc    = center of el range
% els    = el step size
%levels  = vector of levels, default is MATLAB levels
%
if(nargin < 5)
    error('Too few arguments');
    return;
elseif(nargin < 6)
    no_levels=1;
else
    no_levels=0;
end
[rows,cols]=size(grid);
xmin=azc-fix(cols/2)*azs;
xmax=azc+fix(cols/2)*azs;
ymin=elc-fix(rows/2)*els;
ymax=elc+fix(rows/2)*els;
clf
hold on
if(no_levels==1)
    [Z,h]=contour([xmin:azs:xmax],[ymin:els:ymax],grid);
else
    [Z,h]=contour([xmin:azs:xmax],[ymin:els:ymax],grid,levels);
end
box on
clabel(Z,h);
xlabel('Azimuth');
ylabel('Elevation');
